import functools


class Solution(object):
    def soupServings(self, n):
        if n >= 10000:
            return 1

        @functools.cache
        def search(a, b):
            if a <= 0:
                if b <= 0:
                    return 0.5
                else:
                    return 1
            else:
                if b <= 0:
                    return 0
                else:
                    return 0.25 * search(a - 100, b) + 0.25 * search(a - 75, b - 25) + 0.25 * search(a - 50,
                                                                                                  b - 50) + 0.25 * search(
                        a - 25, b - 75)
        return search(n, n)
